package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.ComplaintCertificateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ConstructionComplaintMapper;
import com.ruoyi.system.domain.ConstructionComplaint;
import com.ruoyi.system.service.IConstructionComplaintService;

/**
 * 施工投诉Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-22
 */
@Service
public class ConstructionComplaintServiceImpl implements IConstructionComplaintService 
{
    @Autowired
    private ConstructionComplaintMapper constructionComplaintMapper;
    @Autowired
    private ComplaintCertificateMapper complaintCertificateMapper;

    /**
     * 查询施工投诉
     * 
     * @param ccId 施工投诉ID
     * @return 施工投诉
     */
    @Override
    public ConstructionComplaint selectConstructionComplaintById(Long ccId)
    {
        ConstructionComplaint constructionComplaint = constructionComplaintMapper.selectConstructionComplaintById(ccId);
        constructionComplaint.setComplaintCertificate(complaintCertificateMapper.selectComplaintCertificateByCid(constructionComplaint.getCcId()));
        return constructionComplaint;
    }

    /**
     * 查询施工投诉列表
     * 
     * @param constructionComplaint 施工投诉
     * @return 施工投诉
     */
    @Override
    public List<ConstructionComplaint> selectConstructionComplaintList(ConstructionComplaint constructionComplaint)
    {
        List<ConstructionComplaint> constructionComplaints = constructionComplaintMapper.selectConstructionComplaintList(constructionComplaint);
        for (int i = 0; i <constructionComplaints.size() ; i++) {
            constructionComplaints.get(i).setComplaintCertificate(complaintCertificateMapper.selectComplaintCertificateByCid(constructionComplaints.get(i).getCcId()));
        }
        return constructionComplaints;
    }

    /**
     * 新增施工投诉
     * 
     * @param constructionComplaint 施工投诉
     * @return 结果
     */
    @Override
    public int insertConstructionComplaint(ConstructionComplaint constructionComplaint)
    {constructionComplaint.setCreateTime(DateUtils.getNowDate());
        return constructionComplaintMapper.insertConstructionComplaint(constructionComplaint);
    }

    /**
     * 修改施工投诉
     * 
     * @param constructionComplaint 施工投诉
     * @return 结果
     */
    @Override
    public int updateConstructionComplaint(ConstructionComplaint constructionComplaint)
    {constructionComplaint.setUpdateTime(DateUtils.getNowDate());
        return constructionComplaintMapper.updateConstructionComplaint(constructionComplaint);
    }

    /**
     * 批量删除施工投诉
     * 
     * @param ccIds 需要删除的施工投诉ID
     * @return 结果
     */
    @Override
    public int deleteConstructionComplaintByIds(Long[] ccIds)
    {
        return constructionComplaintMapper.deleteConstructionComplaintByIds(ccIds);
    }

    /**
     * 删除施工投诉信息
     * 
     * @param ccId 施工投诉ID
     * @return 结果
     */
    @Override
    public int deleteConstructionComplaintById(Long ccId)
    {
        return constructionComplaintMapper.deleteConstructionComplaintById(ccId);
    }
}
